﻿package UIComponents
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	
	public class WeaponItemPanel extends Sprite
	{
		public function WeaponItemPanel()
		{
			init();
		}
		
		private var ic:IconContainer;
		public var fm:DisplayObject;
		public var iuserItem:IUseItem;
		public var weaponId:Number;
		public var newFlag:DisplayObject;
		/**
		 * 是否是新的武器 
		 */		
		public var isNewWeapon:Boolean=false;
		
		private function init():void
		{
			this.ic=this.getChildByName("picIcon") as IconContainer;
			this.fm=this.getChildByName("fm");
			this.newFlag=this.getChildByName("newFlag");
		}
		
		public function setItemWeanpon(_iuserItem:IUseItem):void
		{
			reset();
			this.iuserItem=_iuserItem;
			this.weaponId=_iuserItem.itemId;
			this.ic.addPic(_iuserItem.itemPic,_iuserItem.itemName+"："+_iuserItem.description);
			this.fm.visible=false;
			this.isNewWeapon=this.compareWeaponId(this.weaponId);
			this.newFlag.visible=this.isNewWeapon;
		}
		
		private function reset():void
		{
			this.ic.addPic(null);
			this.fm.visible=true;
			this.newFlag.visible=false;
		}
		
		public function setWeaponOld():void
		{
			this.newFlag.visible=false;
			this.isNewWeapon=false;
			FlatInfo.newWeaponObj[weaponId]=null;
			delete FlatInfo.newWeaponObj[weaponId];
		}
		
		private function compareWeaponId(_weaponId:int):Boolean
		{
			var flag:Boolean=FlatInfo.newWeaponObj[_weaponId]==null?false:true;
			
			return flag;
		}
	}
}